$(function(){
	var html = "";
	$("#uploadify").uploadify({
		'method' : 'GET',
		'scriptData':uploadify_data,
		'uploader' : './uploadify/uploadify.swf',
		'script' : script,
		'cancelImg' : './images/cancel.png',
		'folder' : '../api/upload',
		'queueID' : 'fileQueue',
		'auto' : true,
		'multi' : true, 
        'simUploadLimit' : 1, //一次同步上传的文件数目    
		'fileDataName' : "_file",
		'fileExt' : '.png;*.jpg;*.gif',
		'fileDesc' : "*.png *.jpg *.gif",
		"onComplete" : function(event,queueId,fileObj,response,data){
			//alert(response);return;
			html = "";
			response = eval("(" + response + ")");
			if (response.status == 1)
			{
				thumbShow(response.thumb,response.pic);
				//$("#imagesDiv").prepend("<div class='imgWrap'><img src='" + response.thumb+  "'/></div>");

			} else
			{
				jQuery('#uploadify').uploadifyClearQueue();
				html = response.err;
			}

		},
		"onAllComplete" : function(){
			if (html == "")
			{
				html = "上传完成"
				alertTip(html,200);

			} else
			{
				alertTip(html,200);
			}
			html = "";

		},
		"onError" : function(){
			alert('error');
		}
	});

	$(".imgWrap").live("dblclick",function(){
		var _this = $(this);
		$('<div title="提示"><p align="center">删除以下图片？？' + _this.html() + '</p></div>').dialog({
			modal : true,
			width : 200,
			buttons : {
				'确定' : function(){
					_this.remove();
					$(this).dialog("close");
				},
				'取消' : function(){
					$(this).dialog("close");
				}
			}
		});

	});
})

// 操作提示s
function alertTip(tip,width){
	if (!width)
	{
		width = 600;
	}
	$('<div title="提示"><p align="left">' + tip + '</p></div>').dialog({
		modal : true,
		width : width,
		buttons : {
			'确定' : function(){
				$(this).dialog("close");
			}
		}
	});
}